package com.uuah.server.transport.retry;

import com.uuah.server.api.IUuahMessage;
import com.uuah.server.api.transport.retry.IRetryContext;

import java.util.Map;

/**
 *
 * TODO comment ...
 *
 * <p>
 * update record:updator，update time，update content and version
 * </p>
 *
 * @author <a href="jonny_quan@hotmail.com">jonny</a>
 * @date 2009 2009-3-27 下午02:48:24
 * @version 1.0.0
 */
public class RetryContext implements IRetryContext {
	private IUuahMessage[] returnMessages;
	private Map metaInfo;
	private String description;

	public RetryContext(String description) {
		this.description = description;
	}

	public Map getMetaInfo() {
		return metaInfo;
	}

	public void setMetaInfo(Map metaInfo) {
		this.metaInfo = metaInfo;
	}

	public IUuahMessage[] getReturnMessages() {
		return returnMessages;
	}

	public IUuahMessage getFirstReturnMessage() {
		return (returnMessages == null ? null : returnMessages[0]);
	}

	public void setReturnMessages(IUuahMessage[] returnMessages) {
		this.returnMessages = returnMessages;
	}

	public void addReturnMessage(IUuahMessage result) {
		if (returnMessages == null) {
			returnMessages = new IUuahMessage[] { result };
		} else {
			IUuahMessage[] newReturnMessages = new IUuahMessage[returnMessages.length + 1];
			System.arraycopy(newReturnMessages, 0, returnMessages, 0, 1);
			returnMessages = newReturnMessages;
		}
	}

	public String getDescription() {
		return description;
	}
}
